package servicesImp.expertInfo;


import base.IBaseMapperWithoutBLOBs;
import exception.WTException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import services.expertInfo.ExpertBaseServices;
import services.expertInfo.ExpertCompanyServices;
import services.expertInfo.LeaderCheckServices;
import wt.dao.expertInfo.ExpertCompanyMapper;
import wt.entity.expertInfo.ExpertCompany;
import wt.entity.expertInfo.ExpertCompanyExample;
import wt.staticData.TableName;

import java.util.List;

/**
 * Created by Administrator on 2017/10/14.
 */
@Service
public class ExpertCompanyExpertInfoServicesImp extends BaseExpertInfoServicesImp<ExpertCompany, ExpertCompanyExample> implements ExpertCompanyServices {
    @Autowired
    ExpertCompanyMapper expertCompanyMapper;
    @Autowired
    LeaderCheckServices leaderCheckServices;
    @Autowired
    ExpertBaseServices expertBaseServices;
    @Override
    public IBaseMapperWithoutBLOBs< ExpertCompany, ExpertCompanyExample> getMapper() {
        return this.expertCompanyMapper;
    }

    @Override
    public String getTableName() {
        return TableName.EMS_EXPERT_COMPANY;
    }


    @Override
    public ExpertCompany getEntity() {
        return new ExpertCompany();
    }

    @Override
    public ExpertCompanyExample getRecordExample() {
        return new ExpertCompanyExample();
    }

    @Override
    public LeaderCheckServices getLeaderCheckServices() {
        return leaderCheckServices;
    }

    @Override
    public ExpertBaseServices getExpertBaseServices() {
        return expertBaseServices;
    }

    public ExpertCompany expertSelectByExpertIdOnly(String expertId) throws Exception {

        List<ExpertCompany> expertCompanyList = super.expertSelectByExpertId(expertId);
        if (expertCompanyList != null && expertCompanyList.size() > 0) {
            return expertCompanyList.get(0);
        } else {
            return null;
        }
    }


    public ExpertCompany adminSelectByExpertIdOnly(String expertId) throws Exception {
        List<ExpertCompany> expertCompanyList = super.adminSelectByExpertId(expertId);
        if (expertCompanyList != null && expertCompanyList.size() > 0) {
            return expertCompanyList.get(0);
        } else {
            return null;
        }
    }



    @Override
    @Transactional
    public void adminInsertSelective(ExpertCompany expertCompany) throws Exception {
        if (isExistUnauditedRecord(expertCompany.getExpertId())) {
            throw new WTException(WTException.FOUND_NOT_CHECK_DATA);
        }
        super.adminInsertSelective(expertCompany);
    }


    @Deprecated
    @Override
    public List<ExpertCompany> adminSelectByExpertId(String expertId) throws Exception {
        return super.adminSelectByExpertId(expertId);
    }

    @Deprecated
    @Override
    public void expertDeleteByPrimaryKey(String id) throws Exception {
        super.expertDeleteByPrimaryKey(id);
    }

    @Deprecated
    @Override
    public void adminDeleteByPrimaryKey(String id) throws Exception {
        super.adminDeleteByPrimaryKey(id);
    }
    @Deprecated
    @Override
    public List<ExpertCompany> expertSelectByExpertId(String expertId) throws Exception {
        return super.expertSelectByExpertId(expertId);
    }
}
